package org.tlipoca.smsteamuserstore.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.genntii.smdomain.entity.SteamUserStore;

import java.util.ArrayList;
import java.util.List;

@Mapper
public interface SteamUserStoreMapper extends BaseMapper<SteamUserStore> {
    void insertSteamUserStoreBatch(@Param("games") List<SteamUserStore> games);

    @Select("select * from Steam_User_Store where steamid = #{steamid} and is_dlc = false;")
    ArrayList<SteamUserStore> selectSteamUserGameBySteamId(Long steamid);

    @Select("select count(*) from Steam_User_Store where steamid = #{steamid} and is_dlc = false;")
    Integer getGameCount(@Param("steamid") Long steamid);

//    @Select("select playtime_2weeks from Steam_User_Store where steamid = #{steamid}")
//    ArrayList<Integer> getPlayTime2week(@Param("steamid") Long steamid);
//
//    @Select("select playtime_forever from Steam_User_Store where steamid = #{steamid}")
//    ArrayList<Integer> getPlayTimeForever(@Param("steamid")Long steamid);

    @Select("select * from Steam_User_Store where steamid = #{steamid} and is_dlc = false")
    ArrayList<SteamUserStore> getSteamUserStoreList(@Param("steamid")Long steamid);

    @Select("select * " +
            "from Steam_User_Store " +
            "where steamid = #{steamid} and is_dlc = false " +
            "order by playtime_2weeks, playtime_forever desc " +
            "limit #{pageNum}, #{pageSize}")
    ArrayList<SteamUserStore> getSteamUserStoreListToVO(@Param("steamid")Long steamid,
                                                        @Param("pageNum") int pageNum,
                                                        @Param("pageSize") int pageSize);

    @Select("select count(*) " +
            "from Steam_User_Store " +
            "where steamid = #{steamid} and is_dlc = false")
    long getSteamUserStoreCount(@Param("steamid")Long steamid);
}
